<?php
/**
 * Created by PhpStorm.
 * User: wangkai
 * Date: 2017/10/28
 * Time: 11:01
 */

namespace app\modules\controllers;


use app\modules\models\Admin;
use yii\web\Controller;
use Yii;
class PublicController extends Controller
{
    public function actionLogin(){
        session_start();
        var_dump($_SESSION);
        $this->layout=false;
        $model=new Admin;
        if(Yii::$app->request->isPost){
            $post=Yii::$app->request->post();
            if($model->login($post)){
                $this->redirect(['default/index']);
                Yii::$app->end();
            }
           // var_dump($post);
        }
        return $this->render('login',['model'=>$model]);
    }
    public function actionLogout(){
        Yii::$app->session->removeAll();
        if(!isset(Yii::$app->session['admin']['isLogin'])){
            $this->redirect(['public/login']);
            Yii::$app->end();
        }
        $this->goBack();
    }
}